﻿#include "pcrState.h"
QStringList STRType = {"常STR","Y-STR","Mini-STR"};
QStringList STRName = {"Verifiler Plus","BTY44Y案件","新海NHID Mini 25A "};
QStringList STRsys = {"10","10","10"};



// 从数据库初始化数据
void PCRState::init(QString equId){     // equid=""表示取Temp表中数据

    qDebug() << "PCRStateCalculator-初始化数据" << equId;

    canAnalysis = true;

    curChart = PCRState::DELTA_RN;
    curPage = PCRState::RAW;
    showThr = false;

    // 根据设备ID获取expId
    QString expId = "";
    if(equId != ""){
        QSqlDatabase db = dbHelper::openConnection();
        QSqlQuery query(db);
        QString sql = QString("select experimentguid from equipmentinfo where id='%1'").arg(equId);
        query.exec(sql);
        while(query.next()){
            expId = query.value("ExperimentGuid").toString();
        }
        db.close();
    }

    initExpInfo(expId);
    initModelSettings();
    initSampleInfo(expId);
    initFluData(expId);
    initThr();
    initModel();

    calculateAll();


}

// 不需要重新计算模型，只是阈值线变了
void PCRState::calculateHalf(){

//    calFilterData();
//    calThreshold();
    calCt();
    calStandardCurve();
    calGuideData();

}

// 重新计算模型
void PCRState::calculateAll(){

    calFilterData();
    calModel();
    calThreshold();
    calCt();
    calStandardCurve();
    calGuideData();

}

void PCRState::initExpInfo(QString expId){

    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QString sql;
    if(expId == ""){
        sql="SELECT ExperimentName,RunTime,FinishTime FROM ExperimentInfoTemp";
    }else{
        while(query.next()){
            expId = query.value("experimentGuid").toString();
        }
        sql = QString("SELECT ExperimentName,RunTime,FinishTime FROM ExperimentInfo where id='%1'").arg(expId);
    }
    query.exec(sql);
    while (query.next()) {
        experimentName = query.value("ExperimentName").toString();
        experimentRunTime = query.value("RunTime").toString();
        experimentFinishTime = query.value("FinishTime").toString();
    }

}

void PCRState::initModelSettings(){
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QString sql = "Select Name  From ItemCode where IsDefault=1 and DicCode=11";
    query.exec(sql);
    while (query.next()) {
        modelIR = query.value("Name").toString();
    }

    modelFunc = 0;
    modelFilter = 0;
    modelCt = 0;
}

void PCRState::initSampleInfo(QString expId){

    // 更新:
    // samplePannel | posiList | nameList | typeList | channelList | curveList

    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);

    QString sql;
    if(expId == ""){
        sql = "select * from sampleInfoTemp";
    }else{
        sql = QString("select * from sampleInfo where experimentguid='%1'").arg(expId);
    }
    query.exec(sql);
    nameList.clear();
    typeList.clear();
    posiList.clear();
    channelList.clear();
    curveList.clear();
    while(query.next()){

        // 未设置样本名称并且未设置样本类型时，不参与计算
        if(query.value("SampleName").toString() == "" && query.value("SampleType").toString() == ""){       // 样本名和样本类型为空的数据不显示
            continue;
        }

        int posi = query.value("RowNum").toInt()*12 + query.value("ColNum").toInt() + 1;

        stSampleInfo sampleInfo;

        sampleInfo.name = query.value("SampleName").toString();
        sampleInfo.posi = posi;
        sampleInfo.conc = query.value("SampleConc").toDouble();
        sampleInfo.type = query.value("SampleType").toString();
        sampleInfo.id = query.value("ID").toString();
        sampleInfo.channel = QVector<bool>(4, false);
        if(query.value("FAM").toString()=="1"){
            sampleInfo.channel[0] = true;
            channelList[0] = true;
            curveList[posi] = true;
        }if(query.value("VIC").toString()=="1"){
            sampleInfo.channel[1] = true;
            channelList[1] = true;
            curveList[100+posi] = true;
        }if(query.value("ROX").toString()=="1"){
            sampleInfo.channel[2] = true;
            channelList[2] = true;
            curveList[200+posi] = true;
        }if(query.value("CY5").toString()=="1"){
            sampleInfo.channel[3] = true;
            channelList[3] = true;
            curveList[300+posi] = true;
        }

        samplePannel[posi] = sampleInfo;

        posiList[posi] = true;
        nameList[sampleInfo.name] = true;
        typeList[sampleInfo.type] = true;
    }

}

void PCRState::initFluData(QString expId){
    cycleNum = 0;
    rawData.clear();

    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);

    QString sql;

    foreach(stSampleInfo sampleInfo, samplePannel){

        if(expId == ""){
            sql = QString("select f.SampleId,FAM,ROX,CY5,VIC,CyclesNumber "
                                 "From FluorescenceDataTemp f "
                                 "where SampleId='%1' "
                                 "order by CyclesNumber;").arg(sampleInfo.id);
        }else{
            sql = QString("select f.SampleId,FAM,ROX,CY5,VIC,CyclesNumber "
                                 "From FluorescenceData f "
                                 "where SampleId='%1' and experimentguid='%2' "
                                 "order by CyclesNumber;").arg(sampleInfo.id, expId);
        }

        QVector<QPointF> fData;
        QVector<QPointF> rData;
        QVector<QPointF> cData;
        QVector<QPointF> vData;
        query.exec(sql);
        while(query.next()){
            QPointF fpoint=QPointF(query.value("CyclesNumber").toDouble(),query.value("FAM").toDouble());
            fData.append(fpoint);
            QPointF rpoint=QPointF(query.value("CyclesNumber").toDouble(),query.value("ROX").toDouble());
            rData.append(rpoint);
            QPointF cpoint=QPointF(query.value("CyclesNumber").toDouble(),query.value("CY5").toDouble());
            cData.append(cpoint);
            QPointF vpoint=QPointF(query.value("CyclesNumber").toDouble(),query.value("VIC").toDouble());
            vData.append(vpoint);
            cycleNum = std::max(query.value("CyclesNumber").toDouble(), cycleNum);
        }
        if(!fData.isEmpty() && sampleInfo.channel[0]) {
            rawData[0+sampleInfo.posi] = fData;
        }else{
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]CalFilterData - insert fData false - DataLength:" + QString::number(fData.size()) + (sampleInfo.channel[0]?"true":"false"));
        }if(!vData.isEmpty() && sampleInfo.channel[1]) {
            rawData[100+sampleInfo.posi] = vData;
        }else{
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]CalFilterData - insert vData false - DataLength:" + QString::number(vData.size()) + (sampleInfo.channel[1]?"true":"false"));
        }if(!rData.isEmpty() && sampleInfo.channel[2]) {
            rawData[200+sampleInfo.posi] = rData;
        }else{
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]CalFilterData - insert rData false - DataLength:" + QString::number(rData.size()) + (sampleInfo.channel[2]?"true":"false"));
        }if(!cData.isEmpty() && sampleInfo.channel[3]) {
            rawData[300+sampleInfo.posi] = cData;
        }else{
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]CalFilterData - insert cData false - DataLength:" + QString::number(cData.size()) + (sampleInfo.channel[3]?"true":"false"));
        }
    }
    if(cycleNum <= 5){
        canAnalysis = false;
    }

}

void PCRState::initThr(){
    for(int i = 0; i < 4; i ++){
        thrList[i] = 0;
        thrList_log[i] = 0;
        thrList_diff[i] = 0;
        thrList_Rn[i] = 0;
        thrList_logRn[i] = 0;
    }
}

void PCRState::initModel(){
    foreach(stSampleInfo sampleInfo, samplePannel){
        for(int i = 0; i < 4; i ++){
            if(sampleInfo.channel[i]){
                int curve = i*100 + sampleInfo.posi;
                modelList[curve] = new QPCRModel::Model();
                if(rawData.contains(curve)){
                    modelList[curve]->setRawData(rawData[curve]);
                }else{
//                    qDebug() << "";
                }
            }
        }
    }
}

void PCRState::calFilterData(){
    rawData_filter.clear();
    for(auto iter = modelList.begin(); iter != modelList.end(); iter ++){
        if(!rawData.contains(iter.key())){
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]CalFilterData - rawData out-of-range - " + QString::number(iter.key()));
        }
        if(modelFilter >= 0){
            rawData_filter[iter.key()] = QPCRModel::Model::filter(rawData[iter.key()]);
        }else{
            rawData_filter[iter.key()] = rawData[iter.key()];
        }
    }
}


// 模型计算
void PCRState::calModel(){

    if(! canAnalysis){
        return;
    }
    for(auto iter = modelList.begin(); iter != modelList.end(); iter ++){

        QPCRModel::Model* model = iter.value();
        model->setParam(QPCRModel::Model::FUNC_TYPE, modelFunc);
        model->startCalculation();
        // 内标值更新
        if(CHANNELLIST[iter.key()/100] == modelIR){
            rangeIR[iter.key()%100] = model->getTopValue() - model->getBgValue();
        }
    }
}


// 阈值线计算（绝对阈值）
void PCRState::calThreshold(){
    foreach(CHANNEL channel, channelList.keys()){
        thrList[channel] = 0;
        thrList_log[channel] = 0;
        thrList_diff[channel] = 0;
        thrList_Rn[channel] = 0;
        thrList_logRn[channel] = 0;
    }

    if(modelCt < 0){        // 绝对阈值
        for(auto iter = modelList.begin(); iter != modelList.end(); iter ++){
            QPCRModel::Model* model = iter.value();
            CURVE curve = iter.key();

            int endRange = 15;  // 是否自动基线

            int channel = curve / 100;

            if(channel < 0 || channel >= 4){
                LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]CalThreshold - Wrong Curve Idx - " + QString::number(curve));
            }

            thrList[channel]        = std::max(thrList[channel],        model->getThreshold(endRange, QPCRModel::Model::DELTA_RN));
            thrList_log[channel]    = std::max(thrList_log[channel],    model->getThreshold(endRange, QPCRModel::Model::LOG_DELTA_RN));
            thrList_Rn[channel]     = std::max(thrList_Rn[channel],     model->getThreshold(endRange, QPCRModel::Model::RN));
            thrList_logRn[channel]  = std::max(thrList_logRn[channel],  model->getThreshold(endRange, QPCRModel::Model::LOG_RN));
            thrList_diff[channel]   = std::max(thrList_diff[channel],   model->getThreshold(QPCRModel::Model::DELTA_RN) / rangeIR[iter.key()%100]);
        }
    }else{
        showThr = false;
    }
}

void PCRState::changeThreshold(CHANNEL channel, double value){


    switch(curChart){
    case PCRState::RN:
        if(!thrList_Rn.contains(channel)){
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]ChangeThreshold - channel not exist - " + QString::number(channel));
        }
        thrList_Rn[channel] = value;
        thrList_logRn[channel] = std::log10(value);
        break;
    case PCRState::LOG_RN:
        if(!thrList_logRn.contains(channel)){
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]ChangeThreshold - channel not exist - " + QString::number(channel));
        }
        thrList_logRn[channel] = value;
        thrList_Rn[channel] = pow(10, value);
        break;
    case PCRState::DELTA_RN:
        if(!thrList.contains(channel)){
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]ChangeThreshold - channel not exist - " + QString::number(channel));
        }
        thrList[channel] = value;
        thrList_log[channel] = std::log10(value);
        break;
    case PCRState::LOG_DELTA_RN:
        if(!thrList_log.contains(channel)){
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]ChangeThreshold - channel not exist - " + QString::number(channel));
        }
        thrList_log[channel] = value;
        thrList[channel] = pow(10, value);
        break;
    case PCRState::NORM:
        if(!thrList_diff.contains(channel)){
            LogHelperJ::write("ERROR: [CLASS]PCRStateCalculator [FUNC]ChangeThreshold - channel not exist - " + QString::number(channel));
        }
        thrList_diff[channel] = value;
        break;
    default:
        break;
    }

    calculateHalf();
}

// 计算Ct
void PCRState::calCt(){

    if(! canAnalysis){
        return;
    }

    if(modelCt >= 0){    // 1. 相对阈值
        for(auto iter = modelList.begin(); iter != modelList.end(); iter ++){
            Ct[iter.key()] = iter.value()->getCt_relative(modelCt);
        }
    }else{         // 2. 绝对阈值：根据阈值线更新Ct
        for(auto iter = modelList.begin(); iter != modelList.end(); iter ++){
            CHANNEL channel = iter.key() / 100;
            POSI    posi    = iter.key() % 100;
            double threshold;
            if(curChart == PCRState::NORM){       // 归一化
                threshold = thrList_diff[channel] * rangeIR[posi];
                Ct[iter.key()] = iter.value()->getCt(threshold, QPCRModel::Model::DELTA_RN);
            }else if(curChart == PCRState::LOG_DELTA_RN || curChart == PCRState::DELTA_RN){   // Delta
                threshold = thrList[channel];
                Ct[iter.key()] = iter.value()->getCt(threshold, QPCRModel::Model::DELTA_RN);
            }else{          // Rn
                threshold = thrList_Rn[channel];
                Ct[iter.key()] = iter.value()->getCt(threshold, QPCRModel::Model::RN);
            }
        }
    }

    // 平均Ct值计算
    foreach(CHANNEL channel, channelList.keys()){
        avgCt[channel] = 0;
        double ctNum = 0;
        foreach(POSI posi, posiList.keys()){
            CURVE curve = channel*100 + posi;
            if(Ct[curve] != 0 || !std::isinf(Ct[curve])){
                avgCt[channel] += Ct[curve];
                ctNum ++;
            }
        }
        avgCt[channel] /= ctNum;
    }

}


// 计算标准曲线
void PCRState::calStandardCurve(){

    if(! canAnalysis){
        return;
    }


    QSet<POSI> standardPosiList;
    foreach(stSampleInfo sample, samplePannel){
        if(sample.type.contains("标准")){
            standardPosiList.insert(sample.posi);
        }
    }

    // 计算每个通道的返回结果
    standardLine.clear();
    foreach(CHANNEL channel, channelList.keys()){
        QVector<QPointF> pointList;
        // x: log10(浓度)  y: Ct
        foreach(POSI posi, standardPosiList){
            CURVE curve = channel*100+posi;
            if(!modelList.contains(curve)){
                continue;
            }
            double Ct;
            if(modelCt < 0 || modelIR==CHANNELLIST[channel]){ // 绝对阈值和内标的情况下，阈值使用Rn算
                double threshold;
                if(curChart==PCRState::NORM){
                    threshold = thrList_diff[channel] * rangeIR[posi];
                    Ct = modelList[curve]->getCt(threshold, QPCRModel::Model::DELTA_RN);
                }else if(curChart == PCRState::RN || curChart == PCRState::LOG_RN){
                    threshold = thrList_Rn[channel];
                    Ct = modelList[curve]->getCt(threshold, QPCRModel::Model::RN);
                }else{
                    threshold = thrList[channel];
                    Ct = modelList[curve]->getCt(threshold, QPCRModel::Model::DELTA_RN);
                }
            }else{
                Ct = modelList[curve]->getCt_relative(modelCt);
            }
            double Conc = samplePannel[posi].conc;
            if(Ct != 0){
                pointList.append(QPointF(log10(Conc), Ct));
            }
        }
        double k, b;

        QPCRModel::Model::linearFitting(pointList, &k, &b);


        standardLine[channel] = QVector<double>();
        standardLine[channel].append(k);
        standardLine[channel].append(b);
        E[channel] = pow(10, -1.0/k);

    }

    // 每条曲线的浓度 + 平均浓度
    concList.clear();
    avgConcList.clear();
    foreach(CHANNEL channel, channelList.keys()){
        double k = standardLine[channel][0];
        double b = standardLine[channel][1];

        double num = 0;
        avgConcList[channel] = 0;
        foreach(POSI posi, posiList.keys()){
            int curve = channel*100 + posi;
            if(!modelList.contains(curve)){
                continue;
            }
            double Ct;
            if(modelCt < 0 || modelIR==CHANNELLIST[channel]){
                double threshold;
                if(curChart==PCRState::NORM){
                    threshold = thrList_diff[channel] * rangeIR[posi];
                    Ct = modelList[curve]->getCt(threshold, QPCRModel::Model::DELTA_RN);
                }else if(curChart == PCRState::RN || curChart == PCRState::LOG_RN){
                    threshold = thrList_Rn[channel];
                    Ct = modelList[curve]->getCt(threshold, QPCRModel::Model::RN);
                }else{
                    threshold = thrList[channel];
                    Ct = modelList[curve]->getCt(threshold, QPCRModel::Model::DELTA_RN);
                }
            }else{
                Ct = modelList[curve]->getCt_relative(modelCt);
            }
            if(CHANNELLIST[channel] == modelIR){
                concList[curve] = 0;
                standardPoint[curve] = QPointF(0, 0);
            }else if(samplePannel[posi].type.contains("标准")){
                // 标准品的浓度
                concList[curve] = samplePannel[posi].conc;
                standardPoint[curve] = QPointF(log10(samplePannel[posi].conc), Ct);
            }else if(Ct > 0){
                concList[curve] = pow(10, (Ct - b) / k);
                avgConcList[channel] += concList[curve];
                standardPoint[curve] = QPointF((Ct-b)/k, Ct);
                num ++;
            }else{
                concList[curve] = 0;
                standardPoint[curve] = QPointF(0, 0);
            }

        }
        if(num == 0){
            avgConcList[channel];
        }else{
            avgConcList[channel] /= num;
        }
    }

}

void PCRState::updateCurveState(){
    foreach(CURVE curve, curveList.keys()){
        POSI posi = curve % 100;
        CHANNEL channel = curve / 100;
        if(posiList[posi] && channelList[channel]
                          && typeList.contains(samplePannel[posi].type) && typeList[samplePannel[posi].type]
                          && nameList.contains(samplePannel[posi].name) && nameList[samplePannel[posi].name]){
            curveList[curve] = true;
        }else{
            curveList[curve] = false;
        }
    }

}


// 计算下游操作建议
void PCRState::calGuideData(){

    if(!canAnalysis){
        qDebug() << "原始数据错误，无法计算指导建议";
        canGuide = false;
        return;
    }
    QVector<QStringList> dataList;

    foreach(CURVE curve, curveList.keys()){
        QStringList list;
        int posi = curve % 100;
        int channel = curve / 100;
        list.append(getPosiName(posi));
        list.append(samplePannel[posi].name);
        list.append(samplePannel[posi].type);
        list.append(CHANNELLIST[channel]);
        list.append(QString::number(Ct[curve]));
        list.append(QString::number(concList[curve]));
        dataList.append(list);
    }

    table1Data = dataList;
    table2Data.clear();
    if(typeList.contains("标准") || typeList.contains("标准品")){
        table();
        canGuide = true;
    }else{
        qDebug() << "标准品不存在，无法计算指导建议";
        canGuide = false;
    }

//    dataList数据格式：
//    ("A4", "Sample1", "未知", "FAM", "26.4555", "2.46524")
//    ("A4", "Sample1", "未知", "VIC", "24.5657", "1.68111")
//    ("A4", "Sample1", "未知", "ROX", "25.0695", "1.64822")
//    ("A4", "Sample1", "未知", "CY5", "25.0984", "0")
//    ("A5", "Sample1", "未知", "FAM", "0", "0")
//    ("A5", "Sample1", "未知", "VIC", "24.333", "1.95948")
//    ("A5", "Sample1", "未知", "ROX", "24.8935", "1.85199")
//    ("A5", "Sample1", "未知", "CY5", "25.2792", "0")
//    ...


}
// 表格1
void PCRState::table()
{
    int k = 0;
    double JCV = 0;
    for(int i=0;i<table1Data.size();i++){
        QStringList rowdata = table1Data[i];
        QString cell_valueYG = rowdata[3];
        QString cell_valueJC = rowdata[2];
        if(cell_valueJC=="标准品"&&cell_valueYG=="ROX"){
            double cell_valueJCV = rowdata[4].toDouble();
            QString BZP6 = QString::number(cell_valueJCV,'f',4);
            double bzp6 = BZP6.toDouble();
            JCV +=bzp6;
            k++;
        }
    }
    double t = JCV/k;
    QStringList ybmsame;
    for (int i = 0; i < table1Data.size(); i++) {
        QStringList rowdata = table1Data[i];
        QString cell_value = rowdata[1];
        QString cell_value2 =  rowdata[2];
        if(ybmsame.contains(cell_value)&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){

        }else if(!ybmsame.contains(cell_value)&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){
            ybmsame.append(cell_value);
        }
    }
    QList<int> ybmnum;
    QList<double> AL;
    QList<double> AS;
    QList<double> Y;
    QList<double> CQ;
    for(int i=0;i<ybmsame.length();i++){
        ybmnum.append(0);
        AL.append(0);
        AS.append(0);
        Y.append(0);
        CQ.append(0);
    }
    for (int i = 0; i < table1Data.size(); i=i+4) {
        QStringList rowdata = table1Data[i];
        QString cell_value = rowdata[1];
        for(int j = 0;j<ybmsame.length();j++){
            if(cell_value==ybmsame[j]){
                double cell_valueAL = QString::number(table1Data[i+2][5].toDouble(),'f',2).toDouble();
                double cell_valueAS = QString::number(table1Data[i+1][5].toDouble(),'f',2).toDouble();
                double cell_valueY = QString::number(table1Data[i][5].toDouble(),'f',2).toDouble();
                double cell_valueCQ = QString::number(table1Data[i+3][4].toDouble(),'f',2).toDouble();
                AL[j]+=cell_valueAL;
                AS[j]+=cell_valueAS;
                Y[j]+=cell_valueY;
                CQ[j]+=cell_valueCQ;
                ybmnum[j]++;
            }
        }
    }
    for(int i=0;i < table1Data.size(); i+=4){
        for(int k = 0;k<ybmsame.length();k++){
            QString cell_value = table1Data[i][1];
            QString cell_value2 = table1Data[i][2];
            if(cell_value==ybmsame[k]&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){
                double famn = QString::number(Y[k]/ybmnum[k],'f',2).toDouble();
                double vicn = QString::number(AS[k]/ybmnum[k],'f',2).toDouble();
                double roxn = QString::number(AL[k]/ybmnum[k],'f',2).toDouble();
                double cqv = QString::number(CQ[k]/ybmnum[k],'f',2).toDouble();
                datacu(i,famn,vicn,roxn,cqv,t);
                for(int l=0;l<7;l++){
                    table1Data[i+1].append(" ");
                    table1Data[i+2].append(" ");
                    table1Data[i+3].append(" ");
                }
            }
        }
        QString cell_value = table1Data[i][2];
        if(cell_value.contains("sta",Qt::CaseInsensitive)||cell_value.contains("std",Qt::CaseInsensitive)||cell_value.contains("标准",Qt::CaseInsensitive)){

            for(int l=0;l<7;l++){
                table1Data[i].append(" ");
                table1Data[i+1].append(" ");
                table1Data[i+2].append(" ");
                table1Data[i+3].append(" ");
            }
            table1Data[i][6] = table1Data[i+1][5];
        }
    }

    for(int i = 0; i < table1Data.size(); i ++){
        for(int i = 0; i < 12; i ++){
            if(table1Data[i].size() <= i){
                qDebug() << "Table1Data[" + QString::number(i) + "] LackOfData";
                table1Data[i].append("");
            }
        }
    }

    int tab2row=0;
    for(int i=0;i < table1Data.size(); i+=4){
        for(int k = 0;k<ybmsame.length();k++){
            QString cell_value = table1Data[i][1];
            QString cell_value2 = table1Data[i][2];
            if(!(table1Data[i][12]=="")&&cell_value==ybmsame[k]&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准",Qt::CaseInsensitive))){
                QStringList nullist = {" "," "," "," "," "," "," "," "," "," "," "," "};
                table2Data.append(nullist);
                table2Data[tab2row][0]=table1Data[i][0];
                table2Data[tab2row][1]=table1Data[i][1];
                double famn = QString::number(Y[k]/ybmnum[k],'f',2).toDouble();
                double vicn = QString::number(AS[k]/ybmnum[k],'f',2).toDouble();
                double roxn = QString::number(AL[k]/ybmnum[k],'f',2).toDouble();
                dataca(tab2row,table1Data[i][12].toDouble(),table1Data[i][11].toDouble()
                       ,roxn,vicn,famn);
                tab2row++;
            }
        }
    }
}
// 数据计算总浓度-抑制指数
void PCRState::datacu(int row,double famn,double vicn,double roxn,double cqv,double cqbz){
    double R1,R2,R3,X1;
    QSqlDatabase db = dbHelper::openConnection();
    QString sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("R1");
    QSqlQuery query(db);
    query.exec(sql);
    while (query.next()) {
        R1 = query.value("Num").toDouble();
    }
    sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("R2");
    query.exec(sql);
    while (query.next()) {
        R2 = query.value("Num").toDouble();
    }
    sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("R3");
    query.exec(sql);
    while (query.next()) {
        R3 = query.value("Num").toDouble();
    }
    sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("X1");
    query.exec(sql);
    while (query.next()) {
        X1 = query.value("Num").toDouble();
    }
    table1Data[row].append(QString::number(vicn,'f',2));
    if(famn==0){
        if(vicn<X1){
            table1Data[row].append("un");
            table1Data[row].append("un");
            table1Data[row].append("浓度过低无法判断");
            table1Data[row].append("-");
        }else if(vicn>=X1){
            table1Data[row].append("un");
            table1Data[row].append(QString::number(vicn,'f',2));
            table1Data[row].append("女");
            table1Data[row].append("-");
        }
    }else if(vicn/famn<R1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append("un");
        table1Data[row].append("男");
        table1Data[row].append("-");
    }else if(vicn/famn>=R1&&vicn<=X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append("un");
        table1Data[row].append("男");
        table1Data[row].append("-");
    }else if(vicn/famn>=R1&&vicn/famn<R2&&vicn>X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append(QString::number(vicn-famn,'f',2));
        table1Data[row].append(">70%可能混");
        table1Data[row].append("1:"+QString::number((vicn-famn)/famn,'f',2));
    }else if(vicn/famn>=R2&&vicn/famn<R3&&vicn>X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append(QString::number(vicn-famn,'f',2));
        table1Data[row].append(">85%可能混");
        table1Data[row].append("1:"+QString::number((vicn-famn)/famn,'f',2));
    }else if(vicn/famn>=R3&&vicn>X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append(QString::number(vicn-famn,'f',2));
        table1Data[row].append(">95%可能混");
        table1Data[row].append("1:"+QString::number((vicn-famn)/famn,'f',2));
    }
    if(roxn==0){
        table1Data[row].append("nan");
    }else{
        table1Data[row].append(QString::number(vicn/roxn,'f',2));
    }
    table1Data[row].append(QString::number(cqv-cqbz,'f',2));
}
// 指导建议-稀释
void PCRState::dataca(int row,double ICS,double DI,double AL,double AS,double Y){
    QMap<QString,QString> map;
    for(int i=0;i<STRType.length();i++){
        if(STRType.at(i)=="常STR"){
            QSqlDatabase db = dbHelper::openConnection();
            QString sql=QString("SELECT m.SystemName,m.SystemNum from DataAnalyseConfig d,ModelConfigurationNormal m where m.ID=d.ModelGuid and d.ReagentKitType='%1' and d.ReagentKitName='%2' and d.System='%3' ;")
                    .arg(STRType[i],STRName[i],STRsys[i]);
            QSqlQuery query(db);
            query.exec(sql);
            while (query.next()) {
                map.insert(query.value("SystemName").toString(),query.value("SystemNum").toString());
            }
        }else if(STRType.at(i)=="Y-STR"){
            QSqlDatabase db = dbHelper::openConnection();
            QString sql=QString("SELECT m.SystemName,m.SystemNum from DataAnalyseConfig d,ModelConfigurationY m where m.ID=d.ModelGuid and d.ReagentKitType='%1' and d.ReagentKitName='%2' and d.System='%3' ;")
                    .arg(STRType[i],STRName[i],STRsys[i]);
            QSqlQuery query(db);
            query.exec(sql);
            while (query.next()) {
                map.insert(query.value("SystemName").toString(),query.value("SystemNum").toString());
            }
        }else if(STRType.at(i)=="Mini-STR"){
            QSqlDatabase db = dbHelper::openConnection();
            QString sql=QString("SELECT m.SystemName,m.SystemNum from DataAnalyseConfig d,ModelConfigurationMini m where m.ID=d.ModelGuid and d.ReagentKitType='%1' and d.ReagentKitName='%2' and d.System='%3' ;")
                    .arg(STRType[i],STRName[i],STRsys[i]);
            QSqlQuery query(db);
            query.exec(sql);
            while (query.next()) {
                map.insert(query.value("SystemName").toString(),query.value("SystemNum").toString());
            }
        }
    }
    int a=STRType.indexOf("常STR");
    if(STRType.contains("常STR")&&STRsys.at(a)=="10"){
        map.insert("Da",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Db",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Dc",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Dd",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("De",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("MXa",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXb",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXc",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXd",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXe",QString::number(1.5/DI*(1+(DI-1)/DI)));
        double ASN2=map.value("Md").toDouble()/map.value("Mv").toDouble();
        double ASN3=map.value("Md").toDouble()/4;
        double ASN4=map.value("Md").toDouble()/3;
        double ASN5=map.value("Md").toDouble()/2;
        double ASN6=map.value("Mx").toDouble();
        double d = AL;
        double ALN1 = map.value("La").toDouble();
        double ALN2 = map.value("Da").toDouble()/map.value("Mv").toDouble();
        double ALN3 = map.value("Da").toDouble()/4;
        double ALN4 = map.value("Da").toDouble()/3;
        double ALN5 = map.value("Da").toDouble()/2;
        double ALN6 = map.value("MXa").toDouble();
        double ALN7 = map.value("Lb").toDouble();
        double ALN8 = map.value("Db").toDouble()/map.value("Mv").toDouble();
        double ALN9 = map.value("Db").toDouble()/4;
        double ALN10 = map.value("Db").toDouble()/3;
        double ALN11 = map.value("Db").toDouble()/2;
        double ALN12 = map.value("MXb").toDouble();
        double ALN13 = map.value("Lc").toDouble();
        double ALN14 = map.value("Dc").toDouble()/map.value("Mv").toDouble();
        double ALN15 = map.value("Dc").toDouble()/4;
        double ALN16 = map.value("Dc").toDouble()/3;
        double ALN17 = map.value("Dc").toDouble()/2;
        double ALN18 = map.value("MXc").toDouble();
        double ALN19 = map.value("Ld").toDouble();
        double ALN20 = map.value("Dd").toDouble()/map.value("Mv").toDouble();
        double ALN21 = map.value("Dd").toDouble()/4;
        double ALN22 = map.value("Dd").toDouble()/3;
        double ALN23 = map.value("Dd").toDouble()/2;
        double ALN24 = map.value("MXd").toDouble();
        double ALN25 = map.value("Le").toDouble();
        double ALN26 = map.value("De").toDouble()/map.value("Mv").toDouble();
        double ALN27 = map.value("De").toDouble()/4;
        double ALN28 = map.value("De").toDouble()/3;
        double ALN29 = map.value("De").toDouble()/2;
        double ALN30 = map.value("MXe").toDouble();
        table2Data[row][2] = "常STR";
        if(ICS>=2){
            table2Data[row][2] = map.value("检测方案");
            table2Data[row][3] = "无";
            table2Data[row][11] = map.value("备注");
        }if(ICS<2&&DI<1.5){
            if(AS<ASN2){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(AS>=ASN2&&AS<=ASN3){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN3&&AS<=ASN4){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN4&&AS<=ASN5){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN5&&AS<=ASN6){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN6){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Md").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Md").toDouble()/2));
            }

        }else if(ICS<2&&DI>=1.5&&DI<=4){
            if(d<ALN1){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN1&&d<=ALN2){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN2&&d<=ALN3){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN3&&d<=ALN4){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN4&&d<=ALN5){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN5&&d<=ALN6){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN6){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Da").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Da").toDouble()/2));
            }
        }else if(ICS<2&&DI>4&&DI<=12){
            if(d<ALN7){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN7&&d<=ALN8){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN8&&d<=ALN9){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN9&&d<=ALN10){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN10&&d<=ALN11){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN11&&d<=ALN12){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN12){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Db").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Db").toDouble()/2));
            }
        }else if(ICS<2&&DI>12&&DI<=20){
            if(d<ALN13){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN13&&d<=ALN14){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN14&&d<=ALN15){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN15&&d<=ALN16){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN16&&d<=ALN17){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN17&&d<=ALN18){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN18){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Dc").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Dc").toDouble()/2));
            }
        }else if(ICS<2&&DI>20&&DI<=35){
            if(d<ALN19){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN19&&d<=ALN20){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN20&&d<=ALN21){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN21&&d<=ALN22){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN22&&d<=ALN23){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN23&&d<=ALN24){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN24){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Dd").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Dd").toDouble()/2));
            }
        }else if(ICS<2&&DI>35&&DI<=80){
            if(d<ALN25){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN25&&d<=ALN26){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN26&&d<=ALN27){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN27&&d<=ALN28){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN28&&d<=ALN29){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN29&&d<=ALN30){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN30){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("De").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("De").toDouble()/2));
            }
        }else if(ICS<2&&(DI>80||DI==0)){
            if(map.value("Ni").toInt()==0){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }if(map.value("Ni").toInt()==0){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }
        }else{
            table2Data[row][2] = "常STR";
            table2Data[row][10] = map.value("Mv")+"ul";
            table2Data[row][3] = "无";
        }
    }
    if(STRType.contains("常STR")&&STRsys.at(a)=="15"){
        map.insert("Da*", QString::number(0.3*(1+(DI-1/DI)),'f',2));
        map.insert("Db*", QString::number(0.3*(1+(DI-1/DI)),'f',2));
        map.insert("Dc*", QString::number(0.3*(1+(DI-1/DI)),'f',2));
        map.insert("Dd*", QString::number(0.3*(1+(DI-1/DI)),'f',2));
        map.insert("De*", QString::number(0.3*(1+(DI-1/DI)),'f',2));
        map.insert("MXa*",QString::number(1.5/DI*(1+(DI-1)/DI),'f',2));
        map.insert("MXb*",QString::number(1.5/DI*(1+(DI-1)/DI),'f',2));
        map.insert("MXc*",QString::number(1.5/DI*(1+(DI-1)/DI),'f',2));
        map.insert("MXd*",QString::number(1.5/DI*(1+(DI-1)/DI),'f',2));
        map.insert("MXe*",QString::number(1.5/DI*(1+(DI-1)/DI),'f',2));
        double ASN2=map.value("Md*").toDouble()/map.value("Mv*").toDouble();
        double ASN3=map.value("Md*").toDouble()/15;
        double ASN4=map.value("Md*").toDouble()/12;
        double ASN5=map.value("Md*").toDouble()/10;
        double ASN6=map.value("Md*").toDouble()/8;
        double ASN7=map.value("Md*").toDouble()/6;
        double ASN8=map.value("Md*").toDouble()/4;
        double ASN9=map.value("Md*").toDouble()/2;
        double ASN10=map.value("Mx*").toDouble();
        double d = AL;
        double ALN1 = map.value("La*").toDouble();
        double ALN2 = map.value("Da*").toDouble()/map.value("Mv*").toDouble();
        double ALN3 = map.value("Da*").toDouble()/15;
        double ALN4 = map.value("Da*").toDouble()/12;
        double ALN5 = map.value("Da*").toDouble()/10;
        double ALN6 = map.value("Da*").toDouble()/8;
        double ALN7 = map.value("Da*").toDouble()/6;
        double ALN8 = map.value("Da*").toDouble()/4;
        double ALN9 = map.value("Da*").toDouble()/2;
        double ALN10 = map.value("MXa*").toDouble();
        double ALN11 = map.value("Lb*").toDouble();
        double ALN12 = map.value("Db*").toDouble()/map.value("Mv*").toDouble();
        double ALN13 = map.value("Db*").toDouble()/15;
        double ALN14 = map.value("Db*").toDouble()/12;
        double ALN15 = map.value("Db*").toDouble()/10;
        double ALN16 = map.value("Db*").toDouble()/8;
        double ALN17 = map.value("Db*").toDouble()/6;
        double ALN18 = map.value("Db*").toDouble()/4;
        double ALN19 = map.value("Db*").toDouble()/2;
        double ALN20 = map.value("MXb*").toDouble();
        double ALN21 = map.value("Lc*").toDouble();
        double ALN22 = map.value("Dc*").toDouble()/map.value("Mv*").toDouble();
        double ALN23 = map.value("Dc*").toDouble()/15;
        double ALN24 = map.value("Dc*").toDouble()/12;
        double ALN25 = map.value("Dc*").toDouble()/10;
        double ALN26 = map.value("Dc*").toDouble()/8;
        double ALN27 = map.value("Dc*").toDouble()/6;
        double ALN28 = map.value("Dc*").toDouble()/4;
        double ALN29 = map.value("Dc*").toDouble()/2;
        double ALN30 = map.value("MXc*").toDouble();
        double ALN31 = map.value("Ld*").toDouble();
        double ALN32 = map.value("Dd*").toDouble()/map.value("Mv*").toDouble();
        double ALN33 = map.value("Dd*").toDouble()/15;
        double ALN34 = map.value("Dd*").toDouble()/12;
        double ALN35 = map.value("Dd*").toDouble()/10;
        double ALN36 = map.value("Dd*").toDouble()/8;
        double ALN37 = map.value("Dd*").toDouble()/6;
        double ALN38 = map.value("Dd*").toDouble()/4;
        double ALN39 = map.value("Dd*").toDouble()/2;
        double ALN40 = map.value("MXd*").toDouble();
        double ALN41 = map.value("Le*").toDouble();
        double ALN42 = map.value("De*").toDouble()/map.value("Mv*").toDouble();
        double ALN43 = map.value("De*").toDouble()/15;
        double ALN44 = map.value("De*").toDouble()/12;
        double ALN45 = map.value("De*").toDouble()/10;
        double ALN46 = map.value("De*").toDouble()/8;
        double ALN47 = map.value("De*").toDouble()/6;
        double ALN48 = map.value("De*").toDouble()/4;
        double ALN49 = map.value("De*").toDouble()/2;
        double ALN50 = map.value("MXe*").toDouble();
        table2Data[row][2] = "常STR";
        if(ICS>=2){
            table2Data[row][2] = map.value("检测方案");
            table2Data[row][3] = "无";
            table2Data[row][11] = map.value("备注");
        }if(ICS<2&&DI<1.5){
            if(AS<ASN2){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(AS>=ASN2&&AS<=ASN3){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN3&&AS<=ASN4){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN4&&AS<=ASN5){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN5&&AS<=ASN6){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN6&&AS<=ASN7){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN7&&AS<=ASN8){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN8&&AS<=ASN9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN9&&AS<=ASN10){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN10){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Md*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Md*").toDouble()/2));
            }

        }else if(ICS<2&&DI>=1.5&&DI<=4){
            if(d<ALN1){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN1&&d<=ALN2){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN2&&d<=ALN3){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN3&&d<=ALN4){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN4&&d<=ALN5){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN5&&d<=ALN6){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN6&&d<=ALN7){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN7&&d<=ALN8){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN8&&d<=ALN9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN9&&d<=ALN10){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN10){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Da*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Da*").toDouble()/2));
            }
        }else if(ICS<2&&DI>4&&DI<=12){
            if(d<ALN11){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN11&&d<=ALN12){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN12&&d<=ALN13){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN13&&d<=ALN14){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN14&&d<=ALN15){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN15&&d<=ALN16){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN16&&d<=ALN17){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN17&&d<=ALN18){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN18&&d<=ALN19){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN19&&d<=ALN20){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN20){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Db*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Db*").toDouble()/2));
            }
        }else if(ICS<2&&DI>12&&DI<=20){
            if(d<ALN21){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN21&&d<=ALN22){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN22&&d<=ALN23){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN23&&d<=ALN24){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN24&&d<=ALN25){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN25&&d<=ALN26){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN26&&d<=ALN27){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN27&&d<=ALN28){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN28&&d<=ALN29){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN29&&d<=ALN30){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN30){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Dc*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Dc*").toDouble()/2));
            }
        }else if(ICS<2&&DI>20&&DI<=35){
            if(d<ALN31){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN31&&d<=ALN32){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN32&&d<=ALN33){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN33&&d<=ALN34){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN34&&d<=ALN35){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN35&&d<=ALN36){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN36&&d<=ALN37){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN37&&d<=ALN38){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN38&&d<=ALN39){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN39&&d<=ALN40){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN40){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Dd*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Dd*").toDouble()/2));
            }
        }else if(ICS<2&&DI>35&&DI<=80){
            if(d<ALN41){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN41&&d<=ALN42){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN42&&d<=ALN43){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN43&&d<=ALN44){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN44&&d<=ALN45){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN45&&d<=ALN46){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN46&&d<=ALN47){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN47&&d<=ALN48){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN48&&d<=ALN49){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN49&&d<=ALN50){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN50){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("De*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("De*").toDouble()/2));
            }
        }else if(ICS<2&&(DI>80||DI==0)){
            if(map.value("Ni").toInt()==0){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }if(map.value("Ni").toInt()==0){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }
        }else{
            table2Data[row][10] = map.value("Mv*");
            table2Data[row][3] = "无";
        }
    }
    if(YSTRfl&&STRType.contains("Y-STR")){
        map.insert("YDa",QString::number(1.1*(1+(DI-1)/DI),'f',2));
        map.insert("YDb",QString::number(1.1*(1+(DI-1)/DI),'f',2));
        map.insert("YDc",QString::number(1.1*(1+(DI-1)/DI),'f',2));
        map.insert("YDd",QString::number(1.1*(1+(DI-1)/DI),'f',2));
        map.insert("YDe",QString::number(1.1*(1+(DI-1)/DI),'f',2));
        map.insert("YXa",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("YXb",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("YXc",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("YXd",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("YXe",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        double d = Y;
        double Y1 = map.value("Yd").toDouble()/map.value("Yv").toDouble();
        double Y2 = map.value("Yd").toDouble()/4;
        double Y3 = map.value("Yd").toDouble()/3;
        double Y4 = map.value("Yd").toDouble()/2;
        double Y5 = map.value("Yx").toDouble();
        double Y6 = map.value("YDa").toDouble()/map.value("Yv").toDouble();
        double Y7 = map.value("YDa").toDouble()/4;
        double Y8 = map.value("YDa").toDouble()/3;
        double Y9 = map.value("YDa").toDouble()/2;
        double Y10 = map.value("YDa").toDouble()/1.5;
        double Y11 = map.value("YXa").toDouble();
        double Y12 = map.value("YDb").toDouble()/map.value("Yv").toDouble();
        double Y13 = map.value("YDb").toDouble()/4;
        double Y14 = map.value("YDb").toDouble()/3;
        double Y15 = map.value("YDb").toDouble()/2;
        double Y16 = map.value("YDb").toDouble()/1.5;
        double Y17 = map.value("YXb").toDouble();
        double Y18 = map.value("YDc").toDouble()/map.value("Yv").toDouble();
        double Y19 = map.value("YDc").toDouble()/4;
        double Y20 = map.value("YDc").toDouble()/3;
        double Y21 = map.value("YDc").toDouble()/2;
        double Y22 = map.value("YDc").toDouble()/1.5;
        double Y23 = map.value("YXc").toDouble();
        double Y24 = map.value("YDd").toDouble()/map.value("Yv").toDouble();
        double Y25 = map.value("YDd").toDouble()/4;
        double Y26 = map.value("YDd").toDouble()/3;
        double Y27 = map.value("YDd").toDouble()/2;
        double Y28 = map.value("YDd").toDouble()/1.5;
        double Y29 = map.value("YXd").toDouble();
        double Y30 = map.value("YDe").toDouble()/map.value("Yv").toDouble();
        double Y31 = map.value("YDe").toDouble()/4;
        double Y32 = map.value("YDe").toDouble()/3;
        double Y33 = map.value("YDe").toDouble()/2;
        double Y34 = map.value("YDe").toDouble()/1.5;
        double Y35 = map.value("YXe").toDouble();
        table2Data[row][2] = "Y-STR";
        if(DI<=2){
            if(d<Y1){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y1&&d<=Y2){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y2&&d<=Y3){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y3&&d<=Y4){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y4&&d<=Y5){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y5){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("Yd*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("Yd*").toDouble()/2),'f',2);
            }
        }else if(DI>2&&DI<=4){
            if(d<Y6){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y6&&d<=Y7){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y7&&d<=Y8){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y8&&d<=Y9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y9&&d<=Y10){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y10&&d<=Y11){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y11){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDa*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDa*").toDouble()/2),'f',2);
            }
        }else if(DI>4&&DI<=12){
            if(d<Y12){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y12&&d<=Y13){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y13&&d<=Y14){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y14&&d<=Y15){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y15&&d<=Y16){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y16&&d<=Y17){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y17){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDb*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDb*").toDouble()/2),'f',2);
            }
        }else if(DI>12&&DI<=20){
            if(d<Y18){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y18&&d<=Y19){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y19&&d<=Y20){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y20&&d<=Y21){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y21&&d<=Y22){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y22&&d<=Y23){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y23){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDc*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDc*").toDouble()/2),'f',2);
            }
        }else if(DI>20&&DI<=35){
            if(d<Y24){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y24&&d<=Y25){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y25&&d<=Y26){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y26&&d<=Y27){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y27&&d<=Y28){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y28&&d<=Y29){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y29){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDd*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDd*").toDouble()/2),'f',2);
            }
        }else if(DI>35&&DI<=80){
            if(d<Y30){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y30&&d<=Y31){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y31&&d<=Y32){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y32&&d<=Y33){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y33&&d<=Y34){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y34&&d<=Y35){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y35){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDe*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDe*").toDouble()/2),'f',2);
            }
        }else if(DI>80||DI==0){
            if(map.value("Ni").toInt()==1){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(map.value("Ni").toInt()==0){
                table2Data[row][10] = map.value("");
                table2Data[row][3] = "无";
            }
        }else{
            table2Data[row][10] = map.value("");
            table2Data[row][3] = "无";
        }
    }
    if(miniSTRfl&&STRType.contains("Mini-STR")&&table2Data[row][2]=="mini-STR"){
        map.insert("Ia",QString::number(0.25*(1+(DI-1)/DI),'f',2));
        map.insert("Ib",QString::number(0.25*(1+(DI-1)/DI),'f',2));
        map.insert("Ic",QString::number(0.25*(1+(DI-1)/DI),'f',2));
        map.insert("Id",QString::number(0.25*(1+(DI-1)/DI),'f',2));
        map.insert("Ie",QString::number(0.25*(1+(DI-1)/DI),'f',2));
        map.insert("IXa",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("IXb",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("IXc",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("IXd",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        map.insert("IXe",QString::number(1.2*(1+(DI-1)/DI),'f',2));
        double d = AL;
        double M1 = map.value("Is").toDouble()/map.value("Iv").toDouble();
        double M2 = map.value("Is").toDouble()/4;
        double M3 = map.value("Is").toDouble()/3;
        double M4 = map.value("Is").toDouble()/2;
        double M5 = map.value("Ix").toDouble();
        double M6 = map.value("Ia").toDouble()/map.value("Iv").toDouble();
        double M7 = map.value("Ia").toDouble()/4;
        double M8 = map.value("Ia").toDouble()/3;
        double M9 = map.value("Ia").toDouble()/2;
        double M10 = map.value("IXa").toDouble();
        double M11 = map.value("Ib").toDouble()/map.value("Iv").toDouble();
        double M12 = map.value("Ib").toDouble()/4;
        double M13 = map.value("Ib").toDouble()/3;
        double M14 = map.value("Ib").toDouble()/2;
        double M15 = map.value("IXb").toDouble();
        double M16 = map.value("Ic").toDouble()/map.value("Iv").toDouble();
        double M17 = map.value("Ic").toDouble()/4;
        double M18 = map.value("Ic").toDouble()/3;
        double M19 = map.value("Ic").toDouble()/2;
        double M20 = map.value("IXc").toDouble();
        double M21 = map.value("Id").toDouble()/map.value("Iv").toDouble();
        double M22 = map.value("Id").toDouble()/4;
        double M23 = map.value("Id").toDouble()/3;
        double M24 = map.value("Id").toDouble()/2;
        double M25 = map.value("IXd").toDouble();
        double M26 = map.value("Ie").toDouble()/map.value("Iv").toDouble();
        double M27 = map.value("Ie").toDouble()/4;
        double M28 = map.value("Ie").toDouble()/3;
        double M29 = map.value("Ie").toDouble()/2;
        double M30 = map.value("IXe").toDouble();
        table2Data[row][2] = "mini-STR";
        if(DI<1.5){
            if(AS<M1){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(AS>=M1&&AS<=M2){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(AS>M2&&AS<=M3){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(AS>M3&&AS<=M4){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(AS>M4&&AS<=M5){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(AS>M5){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Is*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Is*").toDouble()/2),'f',2);
            }
        }else if(DI>=1.5&&DI<=4){
            if(d<M6){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M6&&d<=M7){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M7&&d<=M8){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M8&&d<=M9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M9&&d<=M10){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M10){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ia*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ia*").toDouble()/2),'f',2);
            }
        }else if(DI>4&&DI<=12){
            if(d<M11){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M11&&d<=M12){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M12&&d<=M13){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M13&&d<=M14){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M14&&d<=M15){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M15){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ib*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ib*").toDouble()/2),'f',2);
            }
        }else if(DI>12&&DI<=20){
            if(d<M16){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M16&&d<=M17){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M17&&d<=M18){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M18&&d<=M19){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M19&&d<=M20){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M20){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ic*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ic*").toDouble()/2),'f',2);
            }
        }else if(DI>20&&DI<=35){
            if(d<M21){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M21&&d<=M22){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M22&&d<=M23){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M23&&d<=M24){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M24&&d<=M25){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M25){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Id*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Id*").toDouble()/2),'f',2);
            }
        }else if(DI>35&&DI<=80){
            if(d<M26){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M26&&d<=M27){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M27&&d<=M28){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M28&&d<=M29){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M29&&d<=M30){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M30){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ie*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ie*").toDouble()/2),'f',2);
            }
        }else if(DI>80||DI==0){
            table2Data[row][10] = map.value("Iv")+"ul";
            table2Data[row][3] = "无";
        }else{
            table2Data[row][10] = map.value("Iv")+"ul";
            table2Data[row][3] = "无";
        }
    }
    xsui(row,table2Data[row][2],5);
    miniSTRfl=false;
}
// 稀释方案
void PCRState::xsui(int row,QString type,int tx){
    QString valt2 = table2Data[row][3];
    if(!valt2.isNull()){
        if(type=="常STR"){
            if(table2Data[row][3]=="无"){
                table2Data[row][4] = "无";
                table2Data[row][5] = "无";
                table2Data[row][6] = "无";
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=100){
                table2Data[row][4] = table2Data[row][3];
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*table2Data[row][3].toDouble()-tx,'f',2);
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=1000&&table2Data[row][3].toInt()>100){
                table2Data[row][4] = "20";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*20-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toDouble()/20,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toDouble()/20-tx,'f',2);
            }else if(table2Data[row][3].toInt()>1000){
                table2Data[row][4] = "50";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*50-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toDouble()/50,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toDouble()/50-tx,'f',2);
            }
        }else if(type=="Y-STR"){
            if(table2Data[row][3]=="无"){
                table2Data[row][4] = "无";
                table2Data[row][5] = "无";
                table2Data[row][6] = "无";
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=100){
                table2Data[row][4] = table2Data[row][3];
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*table2Data[row][3].toInt()-tx,'f',2);
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=1000&&table2Data[row][3].toInt()>100){
                table2Data[row][4] = "20";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*20-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/20,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/20-tx,'f',2);
            }else if(table2Data[row][3].toInt()>1000){
                table2Data[row][4] = "50";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*50-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/50,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/50-tx,'f',2);
            }
        }else if(type=="mini-STR"){
            if(table2Data[row][3]=="无"){
                table2Data[row][4] = "无";
                table2Data[row][5] = "无";
                table2Data[row][6] = "无";
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=100){
                table2Data[row][4] = table2Data[row][3];
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*table2Data[row][3].toInt()-tx,'f',2);
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=1000&&table2Data[row][3].toInt()>100){
                table2Data[row][4] = "20";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*20-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/20,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/20-tx,'f',2);
            }else if(table2Data[row][3].toInt()>1000){
                table2Data[row][4] = "50";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*50-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/50,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/50-tx,'f',2);
            }
        }
    }
}
// 各个类型数量
QList<int> PCRState::typeNum(){
    QList<int> val;
    int c=0,y=0,m=0,xs=0;
    for(int i=0;i<table2Data.length();i++){
        if(table2Data[i][2].contains("常STR")){
            c++;
        }
    }
    y=table2Data.length();
    for(int i=2;i<table2Data.length();i++){
        if(table2Data[i][2].contains("mini-STR")){
            m++;
        }
    }
    for(int i=2;i<table2Data.length();i++){
        if(!table2Data[i][3].contains("无")){
            xs++;
        }
    }
    val<<table2Data.length()<<c<<y<<m<<xs;
    return val;
}
// 表格筛选
QVector<QStringList> PCRState::tab2Fil(QString type){
    if(type=="Y-STR"){
        YSTRfl=true;
    }
    if(type=="全部"){
        calGuideData();
    }else if(type=="常STR"){
        calGuideData();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][2] != "常STR"){
                table2Data.remove(i);
            }
        }
    }else if(type=="mini-STR"){
        calGuideData();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][2] != "mini-STR"){
                table2Data.remove(i);
            }
        }
    }else if(type=="Y-STR"){
        calGuideData();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][2] != "Y-STR"){
                table2Data.remove(i);
            }
        }
    }else if(type=="需稀释样本"){
        calGuideData();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][3] == "无"){
                table2Data.remove(i);
            }
        }
    }
    if(type=="Y-STR"){
        YSTRfl=false;
    }
    return table2Data;
}



